<template>
  <h6 style="color: crimson">商品与赠品管理--><a href="http://localhost:5173/gift">赠品管理</a>-->修改赠品</h6>
  <el-form ref="queryFormRef" :inline="true" :model="queryForm" class="demo-form-inline">

    <el-form-item label="赠品编码" prop="giftCode">
      <el-input v-model="queryForm.id" style="width: 240px" placeholder="赠品编码" clearable disabled />
    </el-form-item> <br>
    <el-form-item label="赠品名称" prop="giftName">
      <el-input v-model="queryForm.giftName" style="width: 240px" placeholder="赠品名称" clearable />
    </el-form-item><br>
    <el-form-item label="最低库存" prop="minStock">
      <el-input v-model="queryForm.minStock" style="width: 240px" placeholder="最低库存" clearable />
    </el-form-item><br>
    <el-form-item label="赠品单价" prop="marketPrice">
      <el-input v-model="queryForm.marketPrice" style="width: 240px" placeholder="赠品单价" clearable />
    </el-form-item><br>
    <el-form-item label="赠品采购成本" prop="purchasePrice">
      <el-input v-model="queryForm.purchasePrice" style="width: 240px" placeholder="赠品采购成本" clearable />
    </el-form-item><br>
    <el-form-item label="采购部门" >
      <el-input  :value="defaultValue" style="width: 240px"  clearable disabled >
      </el-input>
    </el-form-item><br>
    <el-form-item>
      <el-button type="primary" @click="updateSubmit">保存</el-button>
    </el-form-item>
  </el-form>
</template>

<script setup>
import {ref,reactive,onMounted,getCurrentInstance} from "vue";
import axios from "@/plugins/axios.js";
import {ElMessage} from "element-plus";
import router from "@/router/index.js";
import {giftStore} from "@/stores/GiftModel.js";
const giftModel = giftStore();

const defaultValue = '采购部';

const updateSubmit = () => {
  console.log(giftModel.id)
  axios.postJson('/gift/updateGift',queryForm).then(res=>{
    console.log(res)
    if(res.code == 200){
      ElMessage.success('修改成功')
      router.push('/gift')
    }
  })
}
const queryForm=reactive({
})
onMounted(()=>{
  queryForm.id=giftModel.$id
  queryForm.giftName=giftModel.giftName
  queryForm.minStock=giftModel.minStock
  queryForm.marketPrice= giftModel.marketPrice
  queryForm.purchasePrice=giftModel.purchasePrice


})
</script>

<style >

</style>